package com.smashcrush.client.rest;

import java.util.Map;

import org.jboss.resteasy.client.ProxyFactory;
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

import com.smashcrush.model.BrowserType;
import com.smashcrush.model.ExecuteScriptParameters;

public class RestEasyTest {

	public static void main(String[] args) {
		RegisterBuiltin.register(ResteasyProviderFactory.getInstance());

		ClientBrowserService client = ProxyFactory.create(
				ClientBrowserService.class, "http://localhost:8080");

		final String token = "abc";

		String sessionId = client.openSession(token, BrowserType.FireFox,
				"google.com");

		String script = "import org.openqa.selenium.By\n\n "
				+ "browser.navigate().to(\"http://yahoo.com\")\n "
				+ "browser.findElement(By.xpath(\"/html/body/div/div[3]/div[2]/div/div/div/div[3]/span/div/span/h3/a\")).click()\n";

		ExecuteScriptParameters params = new ExecuteScriptParameters();
		params.setScript(script);

		Map<String, String> ret = client
				.executeScript(token, sessionId, params);

		//
		// ExecuteScriptParameters e = new ExecuteScriptParameters();
		// e.setDomain("google.com");
		// e.setName("a");
		// e.setSessionId(sessionId);
		//
		// client.executeScript(e);

	}

}
